import cv2

def get_player(img,player_template):

    player = cv2.matchTemplate(img, player_template, cv2.TM_CCOEFF_NORMED)
    # 获取匹配结果中的最小值、最大值、最小值坐标和最大值坐标
    min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(player)

    corner_loc = (max_loc[0] + 37, max_loc[1] + 88)
    player_spot = (max_loc[0] + 18, max_loc[1] + 88)
    cv2.circle(img, player_spot, 10, (0, 255, 255), -1)
    print(player_spot[0],player_spot[1])
    cv2.rectangle(img, max_loc, corner_loc, (0,0,255), 5)
    cv2.imshow('Img', img)

def main():
    img = cv2.imread("1_2.png")  # 读取原始图像
    player_template = cv2.imread("people.png")  # 读取模板图像

    get_player(img, player_template)

    cv2.waitKey()
    cv2.destroyAllWindows()

if __name__ == '__main__':
    main()


